<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>useragenttestutil.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_useragent_useragenttestutil.js.html">useragenttestutil.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Shared test function to reset the constants in
<a name="line17"></a> * goog.userAgent.*
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>goog.provide(&#39;goog.userAgentTestUtil&#39;);
<a name="line21"></a>goog.provide(&#39;goog.userAgentTestUtil.UserAgents&#39;);
<a name="line22"></a>
<a name="line23"></a>goog.require(&#39;goog.labs.userAgent.browser&#39;);
<a name="line24"></a>goog.require(&#39;goog.labs.userAgent.engine&#39;);
<a name="line25"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line26"></a>goog.require(&#39;goog.userAgent.keyboard&#39;);
<a name="line27"></a>goog.require(&#39;goog.userAgent.platform&#39;);
<a name="line28"></a>goog.require(&#39;goog.userAgent.product&#39;);
<a name="line29"></a>/** @suppress {extraRequire} */
<a name="line30"></a>goog.require(&#39;goog.userAgent.product.isVersion&#39;);
<a name="line31"></a>
<a name="line32"></a>goog.setTestOnly(&#39;goog.userAgentTestUtil&#39;);
<a name="line33"></a>
<a name="line34"></a>
<a name="line35"></a>/**
<a name="line36"></a> * Rerun the initialization code to set all of the goog.userAgent constants.
<a name="line37"></a> * @suppress {accessControls}
<a name="line38"></a> */
<a name="line39"></a>goog.userAgentTestUtil.reinitializeUserAgent = function() {
<a name="line40"></a>  // Unfortunately we can&#39;t isolate the useragent setting in a function
<a name="line41"></a>  // we can call, because things rely on it compiling to nothing when
<a name="line42"></a>  // one of the ASSUME flags is set, and the compiler isn&#39;t smart enough
<a name="line43"></a>  // to do that when the setting is done inside a function that&#39;s inlined.
<a name="line44"></a>  goog.userAgent.OPERA = goog.labs.userAgent.browser.isOpera();
<a name="line45"></a>  goog.userAgent.IE = goog.labs.userAgent.browser.isIE();
<a name="line46"></a>  goog.userAgent.GECKO = goog.labs.userAgent.engine.isGecko();
<a name="line47"></a>  goog.userAgent.WEBKIT = goog.labs.userAgent.engine.isWebKit();
<a name="line48"></a>  goog.userAgent.MOBILE = goog.userAgent.isMobile_();
<a name="line49"></a>  goog.userAgent.SAFARI = goog.userAgent.WEBKIT;
<a name="line50"></a>
<a name="line51"></a>  // Platform in goog.userAgent.
<a name="line52"></a>  goog.userAgent.PLATFORM = goog.userAgent.determinePlatform_();
<a name="line53"></a>  goog.userAgent.initPlatform_();
<a name="line54"></a>  goog.userAgent.MAC = goog.userAgent.detectedMac_;
<a name="line55"></a>  goog.userAgent.WINDOWS = goog.userAgent.detectedWindows_;
<a name="line56"></a>  goog.userAgent.LINUX = goog.userAgent.detectedLinux_;
<a name="line57"></a>  goog.userAgent.X11 = goog.userAgent.detectedX11_;
<a name="line58"></a>  goog.userAgent.ANDROID = goog.userAgent.detectedAndroid_;
<a name="line59"></a>  goog.userAgent.IPAD = goog.userAgent.detectedIPad_;
<a name="line60"></a>  goog.userAgent.IPHONE = goog.userAgent.detectedIPhone_;
<a name="line61"></a>  goog.userAgent.VERSION = goog.userAgent.determineVersion_();
<a name="line62"></a>
<a name="line63"></a>  // Platform in goog.userAgent.platform.
<a name="line64"></a>  goog.userAgent.platform.VERSION = goog.userAgent.platform.determineVersion_();
<a name="line65"></a>
<a name="line66"></a>  // goog.userAgent.product
<a name="line67"></a>  goog.userAgent.product.init_();
<a name="line68"></a>  goog.userAgent.product.OPERA = goog.userAgent.OPERA;
<a name="line69"></a>  goog.userAgent.product.IE = goog.userAgent.IE;
<a name="line70"></a>  goog.userAgent.product.FIREFOX = goog.userAgent.product.detectedFirefox_;
<a name="line71"></a>  goog.userAgent.product.CAMINO = goog.userAgent.product.detectedCamino_;
<a name="line72"></a>  goog.userAgent.product.IPHONE = goog.userAgent.product.detectedIphone_;
<a name="line73"></a>  goog.userAgent.product.IPAD = goog.userAgent.product.detectedIpad_;
<a name="line74"></a>  goog.userAgent.product.ANDROID = goog.userAgent.product.detectedAndroid_;
<a name="line75"></a>  goog.userAgent.product.CHROME = goog.userAgent.product.detectedChrome_;
<a name="line76"></a>  goog.userAgent.product.SAFARI = goog.userAgent.product.detectedSafari_;
<a name="line77"></a>
<a name="line78"></a>  goog.userAgent.product.VERSION = goog.userAgent.product.determineVersion_();
<a name="line79"></a>
<a name="line80"></a>  // goog.userAgent.keyboard
<a name="line81"></a>  goog.userAgent.keyboard.MAC_KEYBOARD =
<a name="line82"></a>      goog.userAgent.keyboard.determineMacKeyboard_();
<a name="line83"></a>};
<a name="line84"></a>
<a name="line85"></a>
<a name="line86"></a>/**
<a name="line87"></a> * Browser definitions.
<a name="line88"></a> * @enum {string}
<a name="line89"></a> */
<a name="line90"></a>goog.userAgentTestUtil.UserAgents = {
<a name="line91"></a>  GECKO: &#39;GECKO&#39;,
<a name="line92"></a>  IE: &#39;IE&#39;,
<a name="line93"></a>  OPERA: &#39;OPERA&#39;,
<a name="line94"></a>  WEBKIT: &#39;WEBKIT&#39;
<a name="line95"></a>};
<a name="line96"></a>
<a name="line97"></a>
<a name="line98"></a>/**
<a name="line99"></a> * Return whether a given user agent has been detected.
<a name="line100"></a> * @param {string} agent Value in UserAgents.
<a name="line101"></a> * @return {boolean} Whether the user agent has been detected.
<a name="line102"></a> */
<a name="line103"></a>goog.userAgentTestUtil.getUserAgentDetected = function(agent) {
<a name="line104"></a>  switch (agent) {
<a name="line105"></a>    case goog.userAgentTestUtil.UserAgents.GECKO:
<a name="line106"></a>      return goog.userAgent.GECKO;
<a name="line107"></a>    case goog.userAgentTestUtil.UserAgents.IE:
<a name="line108"></a>      return goog.userAgent.IE;
<a name="line109"></a>    case goog.userAgentTestUtil.UserAgents.OPERA:
<a name="line110"></a>      return goog.userAgent.OPERA;
<a name="line111"></a>    case goog.userAgentTestUtil.UserAgents.WEBKIT:
<a name="line112"></a>      return goog.userAgent.WEBKIT;
<a name="line113"></a>  }
<a name="line114"></a>
<a name="line115"></a>  throw Error(&#39;Unrecognized user agent&#39;);
<a name="line116"></a>};
</pre>


</body>
</html>
